package org.luxor.common.netty.protocol;

import io.netty.util.internal.StringUtil;
import org.springframework.util.StringUtils;

/**
 * Netty MessageId VariableHeader
 *
 * @author Mr.yan @date 2024/1/31
 */
public class NettyMessageIdVariableHeader {

    private final String messageId;

    protected NettyMessageIdVariableHeader(String messageId) {
        if (!StringUtils.hasText(messageId)) {
            throw new IllegalArgumentException("messageId is null");
        }
        this.messageId = messageId;
    }

    public static NettyMessageIdVariableHeader from(String messageId) {
        return new NettyMessageIdVariableHeader(messageId);
    }

    public String messageId() {
        return messageId;
    }

    @Override
    public String toString() {
        return StringUtil.simpleClassName(this) +
                '[' +
                "messageId=" + messageId +
                ']';
    }
}
